home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.validation;
-
- import com.extensibility.dom.DOMUtilities;
- import com.extensibility.util.StringUtilities;
- import com.extensibility.util.regexpr.PatternInput;
- import java.util.NoSuchElementException;
- import org.w3c.dom.Node;
-
- class NodePatternInput implements PatternInput {
- protected Node parent;
- protected Node curChild;
- protected Node lastChild;
- protected String curToken;
- protected boolean isOpen;
- protected String defaultNS;
- protected String patternNS;
- protected Node leadInChild;
- protected String candidate;
-
- public NodePatternInput(Node var1, boolean var2, String var3) {
- this.isOpen = var2;
- this.parent = var1;
- this.defaultNS = var3;
- this.patternNS = DOMUtilities.getNodeNamespace(var1, (Node)null, var3);
- this.curChild = this.skipWhitespace(var1.getFirstChild());
- this.curToken = this.nodeToToken(this.curChild);
- }
-
- public NodePatternInput(Node var1, Node var2, boolean var3, String var4) {
- this(var1, var3, var4);
- this.lastChild = var2;
- if (var2 == null) {
- this.curChild = null;
- this.curToken = null;
- }
-
- }
-
- public NodePatternInput(Node var1, Node var2, String var3, boolean var4, String var5) {
- this(var1, var4, var5);
- this.leadInChild = var2;
- this.candidate = var3;
- }
-
- public String nodeToToken(Node var1) {
- if (var1 == null) {
- return null;
- } else {
- return var1.getNodeType() != 3 && var1.getNodeType() != 4 ? DOMUtilities.getNodeFullName(var1, (Node)null, this.defaultNS) : "#PCDATA";
- }
- }
-
- public String peekNext() {
- if (this.curToken == null) {
- throw new NoSuchElementException();
- } else {
- return this.curToken;
- }
- }
-
- public String next() {
- String var1 = this.peekNext();
- if (this.lastChild == this.curChild) {
- this.curChild = null;
- this.curToken = null;
- } else if (this.curChild == this.leadInChild) {
- this.leadInChild = null;
- this.curToken = DOMUtilities.getNameFullName(this.parent, this.candidate, this.defaultNS);
- } else {
- this.curChild = this.skipWhitespace(this.curChild.getNextSibling());
- this.curToken = this.nodeToToken(this.curChild);
- }
-
- return var1;
- }
-
- public boolean hasNext() {
- return this.curToken != null;
- }
-
- Node peekNextNode() {
- if (this.curChild == null) {
- throw new NoSuchElementException();
- } else {
- return this.curChild;
- }
- }
-
- String getPatternNS() {
- return this.patternNS;
- }
-
- Node skipWhitespace(Node var1) {
- return skipWhitespace(var1, this.defaultNS, this.patternNS);
- }
-
- static Node skipWhitespace(Node var0, String var1, String var2) {
- while(var0 != null && (var0.getNodeType() == 8 || var0.getNodeType() == 7 || (var0.getNodeType() == 3 || var0.getNodeType() == 4) && (var0.getNodeValue() == null || StringUtilities.isWhitespace(var0.getNodeValue())))) {
- var0 = var0.getNextSibling();
- }
-
- return var0;
- }
- }
-